#include "level1view.h"

level1view::level1view()
{
    this->resize(1149,702);
    //窗口
    this->setWindowTitle("Fishing Joy");//窗口名字
    this->setWindowIcon(QIcon(":/1/widgetfish_1.png"));//设置图标（在左上角小图标
    //背景
//    QPalette palette;//调色板
//    palette.setBrush(QPalette::Background,QBrush(QPixmap("D:/yangkaiwendeqt/homework_1/photos/level1149_702")));//笔刷，添加背景图片
//    this->setPalette(palette);
    this->setBackgroundBrush(QBrush(QPixmap(":/1/level1149_702.jpg")));
    scence=new QGraphicsScene;
    this->setSceneRect(0,0,this->width()-2,this->height()-2);//注意坐标系统的原点，减去滚动条！
    this->setScene(scence);

    //跟随鼠标
    this->setMouseTracking(true);

//绘制发射器
    pao=new bomb(":/1/pao2_x.png",scence);
    pao->setPos(this->width()/2,this->height());
 //   scence->addItem(pao);

    //鱼
    fish1=new Fish(":/1/fish1.png",scence);
   // fish1->setPos(100,420);
    //scence->addItem(fish1);
    fish2=new Fish(":/1/fish2.png",scence);
  //  fish2->setPos(20,180);
   // scence->addItem(fish2);
    fish3=new Fish(":/1/fish3.png",scence);
  //  fish3->setPos(120,240);
    //scence->addItem(fish3);
    fish4=new Fish(":/1/fish4.png",scence);
  //  fish4->setPos(350,320);
  //  scence->addItem(fish4);
    fish5=new Fish(":/1/fish5.png",scence);
   // fish5->setPos(240,240);
   // scence->addItem(fish5);
    fish6=new Fish(":/1/fish6.png",scence);
   // fish6->setPos(460,610);
    //scence->addItem(fish6);

    //定时器
    timer=new QTimer;
    this->connect(timer,SIGNAL(timeout()),scence,SLOT(advance()));
    timer->start(100);


}

void level1view::resizeEvent(QResizeEvent *event)//注意加类名
{
    this->setBackgroundBrush(QBrush(QPixmap(":/1/level1149_702.jpg").scaled(event->size())));

}

void level1view::mouseMoveEvent(QMouseEvent *event)
{
    //找到鼠标位置
    QPoint p;
    p=event->pos();
    //连接大炮与鼠标
    QLine line(this->width()/2,this->height(),p.x(),p.y());
    QLineF linef(line);
    pao->setRotation(90-linef.angle()-88);

}



